package com.scribbles.user.dao;

import java.io.Serializable;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.scribbles.common.dao.AbstractDAO;
import com.scribbles.common.entity.AppUser;

@Repository
public class UserDAO extends AbstractDAO<AppUser, Serializable>{
	public UserDAO()  {
		super(AppUser.class);
	}

	public AppUser findByUserIdAndPassword(String userId, String password) {
		Query query = em.createNamedQuery("findUserByUserIdAndPassword");
		query.setParameter("userId", userId);
		query.setParameter("password", password);
		return (AppUser) query.getSingleResult();
	}

	public AppUser findByUserId(String userId) {
		Query query = em.createNamedQuery("findUserByUserId");
		query.setParameter("userId", userId);
		return (AppUser) query.getSingleResult();
	}
}
